package com.hnhs.controller;

import com.hnhs.entity.User;
import com.hnhs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/api")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/select")
    public List<User> selectAll(){
        return userService.selectAll();
    }

    @GetMapping("/sbn")
    public List<User> selectByName(String username){
        return userService.selectByName(username);
    }

    @PostMapping("/insert")
    public Integer insert(@RequestBody User user){
        return userService.insert(user);
    }
}
